﻿//-----------------------------------------------------------------------
// <copyright file="ActionVar.cs" company="tuliprules.org">
//     Copyright (c) 2011 tuplelister, tuliprules.org.
// </copyright>
// <summary>This is the ActionVar class.</summary>
//-----------------------------------------------------------------------

namespace Tulip.Rules.Models.Rif.Prd
{
    using System;
    using System.ComponentModel;
    using System.Xml.Serialization;

    /// <summary>
    /// Represents an action variable.
    /// </summary>
    [Serializable]
    [DesignerCategory(@"code")]
    [XmlType(AnonymousType = true, Namespace = "http://www.w3.org/2007/rif#")]
    [XmlRoot(Namespace = "http://www.w3.org/2007/rif#", IsNullable = false)]
    public class ActionVar : IRifPrdElement
    {
        /// <summary>
        /// The var field.
        /// </summary>
        [EditorBrowsable(EditorBrowsableState.Never)]
        private Var varField;

        /// <summary>
        /// The initialization field.
        /// </summary>
        [EditorBrowsable(EditorBrowsableState.Never)]
        private object initializationField;

        /// <summary>
        /// The ordered field.
        /// </summary>
        [EditorBrowsable(EditorBrowsableState.Never)]
        private string orderedField;

        /// <summary>
        /// Initializes a new instance of the <see cref="ActionVar"/> class.
        /// </summary>
        public ActionVar()
        {
            this.orderedField = "yes";
        }

        /// <summary>
        /// Gets or sets a logical variable.
        /// </summary>
        [XmlElement(Order = 0)]
        public Var Var
        {
            get
            {
                return this.varField;
            }

            set
            {
                this.varField = value;
            }
        }

        /// <summary>
        /// Gets or sets a new frame identifer.
        /// </summary>
        [XmlElement("New", typeof(New), Order = 1)]
        [XmlElement("Frame", typeof(Frame), Order = 1)]
        public object Initialization
        {
            get
            {
                return this.initializationField;
            }

            set
            {
                this.initializationField = value;
            }
        }

        /// <summary>
        /// Gets or sets a flag indicating if the list of actions is ordered..
        /// </summary>
        [XmlAttribute("ordered")]
        public string Ordered
        {
            get
            {
                return this.orderedField;
            }

            set
            {
                this.orderedField = value;
            }
        }
    }
}